//
//  ViewpointTableViewCell.m
//  WildDonkey
//
//  Created by 佟小波 on 15/3/29.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "ViewpointTableViewCell.h"
#import "UIButton+InitButton.h"
#import "SurroundingFoodTVController.h"

@implementation ViewpointTableViewCell

- (void)dealloc
{
    [_contentLabel release];
    [super dealloc];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        CGRect rect = [UIScreen mainScreen].bounds;
        
        CGFloat width = rect.size.width;
        CGFloat height=rect.size.height;
        //文本内容
        _contentLabel=[[UILabel alloc] initWithFrame:CGRectMake(8, 8, width-16, 60)];
//        _contentLabel.backgroundColor=[UIColor redColor];
        _contentLabel.numberOfLines=0;
        [self.contentView addSubview:_contentLabel];
        
        
        _foodButton =[UIButton buttonWithFrame:CGRectMake(15, 70, 60, 60) title:nil image:[UIImage imageNamed:@"area_food"]];
        _foodButton.tag=1;
        [_foodButton addTarget:self action:@selector(pressonButton:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_foodButton];
        
        
        _houseButton =[UIButton buttonWithFrame:CGRectMake(90, 70, 60, 60) title:nil image:[UIImage imageNamed:@"area_house"]];
        _houseButton.tag=2;
        [_houseButton addTarget:self action:@selector(pressonButton:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_houseButton];
        
        
        
        _viewButton =[UIButton buttonWithFrame:CGRectMake(165, 70, 60, 60) title:nil image:[UIImage imageNamed:@"area_view"]];
        _viewButton.tag=3;
        [_viewButton addTarget:self action:@selector(pressonButton:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_viewButton];
        
        
        
        _trafficButton =[UIButton buttonWithFrame:CGRectMake(240, 70, 60, 60) title:nil image:[UIImage imageNamed:@"area_traffic"]];
        _trafficButton.tag=4;
        [_trafficButton addTarget:self action:@selector(pressonButton:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_trafficButton];

        
    }
    
    return self;
}


- (void)pressonButton:(UIButton *)btn
{
//    NSLog(@"tag=%ld",(long)btn.tag);
    
    NSNotificationCenter *notificationCenter=[NSNotificationCenter defaultCenter];
    
    [notificationCenter postNotificationName:[NSString stringWithFormat:@"%ld",(long)btn.tag]  object:nil];
}

@end
